package file;

import java.util.ArrayList;
import java.util.List;

public class CategoryList {
	public List<Category> getCategorys() {
		return categorys;
	}

	private List<Category> categorys = new ArrayList<Category>();

	public void addDoc(Doc doc) {
		Category category = getCategory(doc.getCategoryName());
		category.getDocs().add(doc);
	}

	private Category getCategory(String name) {
		for (Category temp : categorys) {
			String tempStr = temp.getName();
			if (tempStr.equals(name)) {
				return temp;
			}
		}
		Category category = new Category(name);
		categorys.add(category);
		return category;
	}
}
